package MyCircularQueue;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

public class Test {
    public static void main(String[] args) {

        Deque<Integer> stack = new ArrayDeque<>();//双端队列的线性实现
        Deque<Integer> stack2 = new ArrayDeque<>();

       stack2.push(1);  //双端队列实现的栈



        Deque<Integer> queue2 = new LinkedList<>();
        Deque<Integer> queue22 = new ArrayDeque<>();

        queue22.offer(1);
        stack.push(1);


        Queue<Integer> queue1 = new LinkedList<>();
        queue1.offer(1);
        queue1.offer(2);
        queue1.offer(3);

        System.out.println(queue1.poll());
        System.out.println(queue1.peek());
    }


}


class QueueExample {
    public static void main(String[] args) {
        // 创建一个队列
        Queue<String> queue = new LinkedList<>();

        // 添加元素到队列
        queue.add("Apple");
        queue.offer("Banana");
        queue.offer("Cherry");

        // 删除并返回队列头部的元素
        String removedElement = queue.remove();
        System.out.println("删除的元素: " + removedElement);

        // 返回队列头部的元素
        String head = queue.element();
        System.out.println("队列头部元素: " + head);

        // 判断队列是否为空
        boolean isEmpty = queue.isEmpty();
        System.out.println("队列是否为空: " + isEmpty);

        // 获取队列的大小
        int size = queue.size();
        System.out.println("队列大小: " + size);

        // 遍历队列并打印元素
        System.out.println("队列元素: ");
        for (String fruit : queue) {
            System.out.println(fruit);
        }

        // 判断队列是否包含指定的元素
        boolean containsElement = queue.contains("Banana");
        System.out.println("队列是否包含Banana: " + containsElement);

        // 清空队列
        queue.clear();
        System.out.println("清空后的队列大小: " + queue.size());
    }
}